package ai.people.netmon.warning.controller;

import ai.people.netmon.framework.domain.gang.construction.vo.LabelLibTreeVO;
import ai.people.netmon.framework.domain.warning.request.label.WarningLabelTreeVO;
import ai.people.netmon.framework.model.response.Result;
import ai.people.netmon.framework.utils.ResultUtil;
import ai.people.netmon.warning.service.WarningLabelTreeService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 标签树接口
 *
 * @author yuanqinglong
 * @date 2022/7/27 19:05
 */
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/v1/label")
public class WarningLabelController {

    @Autowired
    private WarningLabelTreeService warningLabelTreeService;

    @Value("${warning.label.tree.parentId}")
    private Long labelTreeParentId;

    /**
     * 列表标签树
     *
     * @return {@link Result}<{@link List}<{@link LabelLibTreeVO}>>
     */
    @GetMapping("/tree")
    public Result<List<WarningLabelTreeVO>> listLabelTree() {
        return ResultUtil.success(warningLabelTreeService.listLabelTree(labelTreeParentId));
    }
}
